<%@include file="/other/Header.jsp" %>
<jsp:directive.page import="java.sql.*"/>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
 <%
String status = request.getParameter("status")!=null?request.getParameter("status"):"BACK";
String name = request.getParameter("name")!=null?request.getParameter("name"):"null";
String branch = request.getParameter("branch")!=null?request.getParameter("branch"):"null";
String submit = request.getParameter("submit")!=null?request.getParameter("submit"):"null";
 

%>
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
   "http://www.w3.org/TR/html4/loose.dtd">

   <html>

      <head>
         <meta http-equiv="Content-Type" 
            content="text/html; charset=windows-1256">
         <title>   Customer Registration  </title>
      </head>
      <script type="text/javascript" src="<%=basePath%>images\jquery.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>images\jquery.autocomplete.js"></script>
	<link rel="stylesheet" type="text/css"
		href="<%=basePath%>images\jquery.autocomplete.css">
      
         <SCRIPT language=JavaScript>
	 var company_id;
	 var branc_val;
function getSub()
{
//sub_id=document.invoice.example.value;
	company_id=document.custregistration.name.value;
	branc_val=document.custregistration.branch.value;
	document.custregistration.name.focus();
	show_list("val","custregistration");
}
	 /********************/
	  		function show_list(val,frm)
			{			
				var st= company_id;
				document.forms[frm].name.value="";					
				$(document).ready(function(){var data=(st).split("$");$("#search_text").autocomplete(data);});
			
			
			
			
			
			}
			
			
	 /**************/
	 
function mySubmit()
{
  var flag=0;			
  
		 
 			 
			 
			 if(flag==0)
			{ document.custregistration.action = "/Genius/CustomerServlet?flag=1";
			document.custregistration.submit();
		    return true;
		     }
		     
		      
		}		

	 

	 
function isEmailId(string) 
	{
		 
	if(string.search(/^[A-Za-z](([A-Za-z0-9])|(\.[A-Za-z0-9])|(\_[A-Za-z0-9]))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!= -1)
		return true;
	else
		return false;
	}

	
   

	 
	
  </SCRIPT>
      
<body bgcolor="white">

<form name=custregistration method=get action="/Genius/form/customer/CustListReport.jsp"  >
    <table align=center border=1  >
    <%
    if(status.equalsIgnoreCase("I"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> INSERTED SUCCESSFULLY </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("U"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> UPDATED SUCCESSFULLY </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("D"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> DELETED SUCCESSFULLY </font> </td></tr>");
    }
     %>
    <tr><td align=center   colspan=10><font size=4 color=Blue> CUSTOMER SEARCH  </font> <br></td></tr>
    <tr><td align=left colspan=5 >SEARCH BY NAME:&nbsp;&nbsp;&nbsp;<br></td>
   		<td align=left colspan=5><input type=name name= name value=""> <br></td>
   </tr>
   <tr><td align=left colspan=5 >SEARCH BY BRANCH/AREA:&nbsp;&nbsp;&nbsp;<br></td>
   		<td align=left  colspan=5><input type=text name=branch value=""> <br></td>
   </tr>
    <tr><td align=right  colspan=5 ><input type=submit name=submit value="search"   >
 &nbsp;&nbsp;&nbsp;&nbsp;<br></td><td align=left  colspan=5><input type=reset name=reset value="Reset"> <br></td></tr>
    <input type=hidden name=status value=<%=status%>>
   
    
 <%
 if(submit.equalsIgnoreCase("search")) 
 {
 
 %>
 <tr>
  <td align=left colspan=1><font size=2 color=brown >Sr No.</font><br></td>
<td align=left colspan=4><font size=2 color=brown>CUSTOMER NAME</font> <br></td>
 <td align=left colspan=4><font size=2 color=brown>BRANCH NAME</font><br></td>
  

  </tr>
 <%
 String customerquerry="";
 
 if(name.length()>0)
 {
 
  customerquerry="select customer_id,customer_name,area,address1,phone_no1";
     customerquerry=customerquerry+",email_id,contactperson1,contactperson2,mobilecontact1,mobilecontact2 ";
	 customerquerry=customerquerry+" from customer_master where customer_name like '"+name.toUpperCase()+"%' and status='V' order by customer_id ";
  
     
 
 
 }
 else if(branch.length()>0)
 {
   
     customerquerry="select customer_id,customer_name,area,address1,phone_no1";
     customerquerry=customerquerry+",email_id,contactperson1,contactperson2,mobilecontact1,mobilecontact2 ";
	 customerquerry=customerquerry+" from customer_master where area like '"+branch.toUpperCase()+"%' and status='V' order by customer_id ";
  System.out.println("customerquerry:"+customerquerry);
 
 
 }
 else
 {
  
  customerquerry="select customer_id,customer_name,area,address1,phone_no1";
     customerquerry=customerquerry+",email_id,contactperson1,contactperson2,mobilecontact1,mobilecontact2 ";
	 customerquerry=customerquerry+" from customer_master where status='V' order by customer_id ";
  
 
 }
 
 
 
 prst1=con.prepareStatement(""+customerquerry);
  ResultSet rs1=prst1.executeQuery();
  while(rs1.next())
  {
 %>

 
  <tr>
 <td align=left colspan=1><font size=2 color=grey><a href="/Genius/form/customer/CustDisplay.jsp?cust_id=<%=rs1.getString(1).toUpperCase()%>&status=<%=status%>"><%=rs1.getString(1).toUpperCase() %></a></font><br></td>
<td align=left colspan=4><font size=2 color=grey><a href="/Genius/form/customer/CustDisplay.jsp?cust_id=<%=rs1.getString(1).toUpperCase()%>&status=<%=status%>"><%=rs1.getString(2).toUpperCase() %></a> </font><br></td>
 <td align=left colspan=4><font size=2 color=grey><a href="/Genius/form/customer/CustDisplay.jsp?cust_id=<%=rs1.getString(1).toUpperCase()%>&status=<%=status%>"><%=rs1.getString(3).toUpperCase() %></a></font><br></td>
  



</tr>
 
<%}
 
 }
  %> 
</table>     
</form>     
</body>
</html>